package 多线程.多线程;


//多线程常见方法
public class NormalThread {

    private static class MyThread implements Runnable{
        volatile boolean flag = false;
        @Override
        public void run() {
            while (!flag){
                System.out.println(Thread.currentThread().getName()+"正在对线。。。。");
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                System.err.println("被单杀了");
                e.printStackTrace();
            }
            System.out.println("被偷家了");
        }
    }

    public static void main(String[] args) throws InterruptedException {
        MyThread mt = new MyThread();
        Thread thread = new Thread(mt,"奥巴马");
        thread.start();
        Thread.sleep(1000);
        System.out.println(Thread.currentThread().getName()+"开始了，要休眠了");
        mt.flag = true;
    }
}
